home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / checkbox / plugins / disk_info.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-10-12  |  2.0 KB  |  53 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import re
  5. from checkbox.properties import Path
  6. from checkbox.plugin import Plugin
  7.  
  8. class DiskInfo(Plugin):
  9.     filename = Path(default = '/var/log/installer/casper.log')
  10.     
  11.     def register(self, manager):
  12.         super(DiskInfo, self).register(manager)
  13.         self._manager.reactor.call_on('report', self.report)
  14.  
  15.     
  16.     def report(self):
  17.         
  18.         try:
  19.             file = open(self.filename)
  20.         except IOError:
  21.             return None
  22.  
  23.         distributor_regex = '(?P<distributor>[\\w\\-]+)'
  24.         release_regex = '(?P<release>[\\d\\.]+)'
  25.         codename_regex = '(?P<codename>[^_]+)'
  26.         official_regex = '(?P<official>[\\w ]+)'
  27.         architecture_regex = '(?P<architecture>[\\w\\+]+)'
  28.         type_regex = '(?P<type>Binary-\\d+)'
  29.         date_regex = '(?P<date>[^\\)]+)'
  30.         info_regex = '%s %s _%s_ - %s %s (%s )?\\(%s\\)' % (distributor_regex, release_regex, codename_regex, official_regex, architecture_regex, type_regex, date_regex)
  31.         line_regex = "Found label '%s'" % info_regex
  32.         line_pattern = re.compile(line_regex)
  33.         for line in file.readlines():
  34.             match = line_pattern.match(line)
  35.             if match:
  36.                 keys = [
  37.                     'distributor',
  38.                     'release',
  39.                     'codename',
  40.                     'official',
  41.                     'architecture',
  42.                     'date']
  43.                 values = [ match.group(k) for k in keys ]
  44.                 message = dict(zip(keys, values))
  45.                 self._manager.reactor.fire('report-disk', message)
  46.                 break
  47.                 continue
  48.             []
  49.         
  50.  
  51.  
  52. factory = DiskInfo
  53.